﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using Serialize.Linq.Nodes;
using Project.Common;
using NHibernate.Type;
using System.ServiceModel.Web;

namespace Project.ServiceInterface.Base
{
	[ServiceContract]
	public interface IBaseService<T>
	{
		[OperationContract]
		T GetByID(object id);

		[OperationContract]
		void DeleteByID(object id);

		[OperationContract(Name = "GetFirst1")]
		[WebInvoke(BodyStyle=WebMessageBodyStyle.Wrapped)]
		T GetFirst(ExpressionNode criteria, ExpressionNode path, EnumOrder direction);

		[OperationContract(Name = "GetFirst2")]
		[WebInvoke(BodyStyle = WebMessageBodyStyle.Wrapped)]
		T GetFirst(ExpressionNode criteria);

		[OperationContract(Name = "GetFirst3")]
		[WebInvoke(BodyStyle = WebMessageBodyStyle.Wrapped)]
		T GetFirst(ExpressionNode criteria, params LinqOrderSerialized<T>[] orderCollection);

		[OperationContract(Name = "GetFirst4")]
		[WebInvoke(BodyStyle = WebMessageBodyStyle.Wrapped)]
		T GetFirst();

		[OperationContract(Name = "GetFirst5")]
		[WebInvoke(BodyStyle = WebMessageBodyStyle.Wrapped)]
		T GetFirst(ExpressionNode path, EnumOrder direction);

		[OperationContract(Name = "List1")]
		[WebInvoke(BodyStyle = WebMessageBodyStyle.Wrapped)]
		IList<T> List(ExpressionNode path, EnumOrder direction);

		[OperationContract(Name = "List2")]
		[WebInvoke(BodyStyle = WebMessageBodyStyle.Wrapped)]
		IList<T> List();

		[OperationContract(Name = "List3")]
		[WebInvoke(BodyStyle = WebMessageBodyStyle.Wrapped)]
		IList<T> List(string path, string direction);

		[OperationContract(Name = "List4")]
		[WebInvoke(BodyStyle = WebMessageBodyStyle.Wrapped)]
		IList<T> List(params LinqOrderSerialized<T>[] orderCollection);

		[OperationContract(Name = "List5")]
		[WebInvoke(BodyStyle = WebMessageBodyStyle.Wrapped)]
		IList<T> List(string path, EnumOrder direction);

		[OperationContract]
		[WebInvoke(BodyStyle = WebMessageBodyStyle.Wrapped)]
		IList<T> ListIn(string collection, ExpressionNode path);

		[OperationContract(Name = "ListBy1")]
		[WebInvoke(BodyStyle = WebMessageBodyStyle.Wrapped)]
		IList<T> ListBy(ExpressionNode criteria, ExpressionNode path, EnumOrder direction);

		[OperationContract(Name = "ListBy2")]
		[WebInvoke(BodyStyle = WebMessageBodyStyle.Wrapped)]
		IList<T> ListBy(ExpressionNode criteria, string path, EnumOrder direction);

		[OperationContract(Name = "ListBy3")]
		[WebInvoke(BodyStyle = WebMessageBodyStyle.Wrapped)]
		IList<T> ListBy(ExpressionNode criteria, string path, string direction);

		[OperationContract(Name = "ListBy4")]
		[WebInvoke(BodyStyle = WebMessageBodyStyle.Wrapped)]
		IList<T> ListBy(ExpressionNode criteria);

		[OperationContract(Name = "ListBy5")]
		[WebInvoke(BodyStyle = WebMessageBodyStyle.Wrapped)]
		IList<T> ListBy(ExpressionNode criteria, params LinqOrderSerialized<T>[] orderCollection);

		[OperationContract(Name = "ListTopX1")]
		[WebInvoke(BodyStyle = WebMessageBodyStyle.Wrapped)]
		IList<T> ListTopX(ExpressionNode criteria, int count, ExpressionNode path, EnumOrder direction);

		[OperationContract(Name = "ListTopX2")]
		[WebInvoke(BodyStyle = WebMessageBodyStyle.Wrapped)]
		IList<T> ListTopX(ExpressionNode criteria, int count);

		[OperationContract(Name = "ListTopX3")]
		[WebInvoke(BodyStyle = WebMessageBodyStyle.Wrapped)]
		IList<T> ListTopX(ExpressionNode criteria, int count, params LinqOrderSerialized<T>[] orderCollection);

		[OperationContract(Name = "PaginateList1")]
		[WebInvoke(BodyStyle = WebMessageBodyStyle.Wrapped)]
		IList<T> PaginateList(int pageSize, int pageIndex, ref int count, ExpressionNode path, EnumOrder direction);

		[OperationContract(Name = "PaginateList2")]
		[WebInvoke(BodyStyle = WebMessageBodyStyle.Wrapped)]
		IList<T> PaginateList(int pageSize, int pageIndex, ref int count, string path, EnumOrder direction);

		[OperationContract(Name = "PaginateList3")]
		[WebInvoke(BodyStyle = WebMessageBodyStyle.Wrapped)]
		IList<T> PaginateList(int pageSize, int pageIndex, ref int count, string path, string direction);

		[OperationContract(Name = "PaginateList4")]
		[WebInvoke(BodyStyle = WebMessageBodyStyle.Wrapped)]
		IList<T> PaginateList(int pageSize, int pageIndex, ref int count);

		[OperationContract(Name = "PaginateList5")]
		[WebInvoke(BodyStyle = WebMessageBodyStyle.Wrapped)]
		IList<T> PaginateList(int pageSize, int pageIndex, ref int count, params LinqOrderSerialized<T>[] orderCollection);


		[OperationContract(Name = "PaginateListBy1")]
		[WebInvoke(BodyStyle = WebMessageBodyStyle.Wrapped)]
		IList<T> PaginateListBy(int pageSize, int pageIndex, ref int count, ExpressionNode criteria, ExpressionNode path, EnumOrder direction);

		[OperationContract(Name = "PaginateListBy2")]
		[WebInvoke(BodyStyle = WebMessageBodyStyle.Wrapped)]
		IList<T> PaginateListBy(int pageSize, int pageIndex, ref int count, ExpressionNode criteria, string path, EnumOrder direction);

		[OperationContract(Name = "PaginateListBy3")]
		[WebInvoke(BodyStyle = WebMessageBodyStyle.Wrapped)]
		IList<T> PaginateListBy(int pageSize, int pageIndex, ref int count, ExpressionNode criteria);

		[OperationContract(Name = "PaginateListBy4")]
		[WebInvoke(BodyStyle = WebMessageBodyStyle.Wrapped)]
		IList<T> PaginateListBy(int pageSize, int pageIndex, ref int count, ExpressionNode criteria, string path, string direction);

		[OperationContract(Name = "PaginateListBy5")]
		[WebInvoke(BodyStyle = WebMessageBodyStyle.Wrapped)]
		IList<T> PaginateListBy(int pageSize, int pageIndex, ref int count, ExpressionNode criteria, params LinqOrderSerialized<T>[] orderCollection);

		[OperationContract]
		[WebGet(UriTemplate="Count")]
		int Count();

		[OperationContract]
		[WebInvoke(BodyStyle = WebMessageBodyStyle.Wrapped)]
		int CountBy(ExpressionNode criteria);

		#region Basic Operation
		[OperationContract]
		void Save(T entity);

		[OperationContract]
		void Update(T entity);

		[OperationContract]
		void Delete(T entity);

		#endregion

		#region Update Operation
		[OperationContract]
		void SaveOrUpdate(T model);

		[OperationContract]
		T Merge(T entity);

		[OperationContract]
		void Persist(T entity);

		#endregion
	}

	[ServiceContract]
	public interface IBaseService
	{

	}
}
